package Lee_code;

public class Lee_518_2 {
    public int change(int amount, int[] coins) {
        int len = coins.length;
        int[] dp = new int[amount+1];
        dp[0] = 1;
        // 遍历顺序不同, 先物品后背包还是先背包后物品
        for (int i=0; i<len; i++){
            for (int j=coins[i]; j<=amount; j++){
                dp[j] = dp[j] + dp[j-coins[i]];
            }
        }
        return dp[amount];
    }
}
